class NumArray(object):

    def __init__(self, nums):
        """
        :type nums: List[int]
        """
        self.nums = nums
        self.prex = self.nums.copy()
        for i in range(1, len(self.nums)):
            self.prex[i] += self.prex[i - 1]


    def sumRange(self, left, right):
        """
        :type left: int
        :type right: int
        :rtype: int
        """
        if left == 0:
            return self.prex[right]
        else:
            return self.prex[right] - self.prex[left - 1]